﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KraveEntities;
using KraveDAL;

public partial class reservation : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      
    }
   

    protected void Button1_Click1(object sender, EventArgs e)
    {
        Reservation res = new Reservation();
        ReservationDAL rd = new ReservationDAL();

        LoginBO lg = new LoginBO();
        LoginDAL ld = new LoginDAL();

        res.Name = TextBox1.Text;
        res.Email = TextBox2.Text;
        res.PNo = TextBox3.Text;
        res.Mobile = TextBox4.Text;
        res.Address = TextBox5.Text;
        res.PostalCode = Convert.ToInt32(TextBox6.Text);
        res.Date = DropDownList1.Text + "/" + DropDownList2.Text + "/" + DropDownList3.Text;
        res.StartTime = DropDownList4.Text + ":" + DropDownList5.Text;
        res.EndTime = DropDownList7.Text + ":" + DropDownList8.Text;
        res.EventName = DropDownList10.Text;
        res.MaleGuest = Convert.ToInt32(TextBox8.Text);
        res.FemaleGuest = Convert.ToInt32(TextBox9.Text);
        res.GuestOfHonour = TextBox10.Text;
        res.Locaion = TextBox11.Text;
        res.Reference = TextBox12.Text;
        res.Comments = TextBox13.Text;
        res.Status = "reserved";

        bool rValue1 = rd.AddReservation(res);

        int id = rd.get_id();

        lg.Id = id;
        lg.Password = "123456";
        lg.Type = "client";

        bool rValue2 = ld.save_login(lg);

        if (rValue1 == true && rValue2 == true)
        {
            Response.Redirect("ressuccessful.aspx");
        }
        else
        {
            Response.Redirect("reservationError.aspx");
        }
    }
}